using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

/* 
Copyright (c) Microsoft Corporation.  All rights reserved.
Use of this sample source code is subject to the terms of the Microsoft license 
agreement under which you licensed this sample source code and is provided AS-IS.
If you did not accept the terms of the license agreement, you are not authorized 
to use this sample source code.  For the terms of the license, please see the 
license agreement between you and Microsoft.
*/

namespace TabbedWebBrowser
{
    public partial class EnterAUrlLForm : Form
    {
        public EnterAUrlLForm()
        {
            InitializeComponent();

            // Display the Soft Input Panel
            inputPanel1.Enabled = true;
        }

        private string GetNewURL()
        {	// Generate the URL from user input.

            if (textBox_host.ToString().Length == 0) return null;

            StringBuilder url = new StringBuilder();

            url.Append("http://");
            url.Append(comboBox_www.SelectedItem.ToString());
            url.Append(".");
            url.Append(textBox_host.Text);
            url.Append(".");
            url.Append(comboBox_dotcom.SelectedItem.ToString());

            // Sometimes spaces might sneak into the URL, so strip them out.
            url.Replace(" ", "");

            return url.ToString();
        }


        private void menuItem_opencurrenttab_Click(object sender, EventArgs e)
        {
            // Get the URL and return the necessary values so that it
            // is opened in the current tab.

            // Generate a string.
            BrowserForm.newUrl = GetNewURL();
            BrowserForm.openInNewTab = false;

            // Hide the Soft Input Panel
            inputPanel1.Enabled = false;

            // Close this form
            this.Close();
        }

        private void menuItem_opennewtab_Click(object sender, EventArgs e)
        {
            // Get the URL and return the necessary values so that
            // it is opened in a new tab.

            // Generate a string.
            BrowserForm.newUrl = GetNewURL();
            BrowserForm.openInNewTab = true;

            // Hide the Soft Input Panel
            inputPanel1.Enabled = false;

            // Close this form
            this.Close();

        }

        private void menuItem_left_Click(object sender, EventArgs e)
        {
            // The user select Cancel - close the form.
            BrowserForm.newUrl = null;

            // Hide the Soft Input Panel
            inputPanel1.Enabled = false;

            // Close this form
            this.Close();
        }


    }
}